package com.xiaotu.dao.sw;

import com.xiaotu.vo.SwErrorCorrectionVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author zhangxiao
 * @create 2021-10-09 16:01
 */
public interface SwErrorCorrectionMapper {

    @Select("<script>" +
            " SELECT " +
            " t2.nick_name, " +
            " t2.avatar_url, " +
            " t2.wx_phone, " +
            " t1.error_id, " +
            " t1.error_content, " +
            " t1.create_time, " +
            " t3.NAME starname, " +
            " t3.imagesurl, " +
            " t3.occupation  " +
            "FROM " +
            " tab_sw_error t1 " +
            " LEFT JOIN tab_wx_user t2 ON t1.user_id = t2.userid " +
            " LEFT JOIN tab_star_info t3 ON t1.star_id = t3.starid  " +
            "WHERE " +
            " t1.handle_status = #{handleStatus}  " +
            "ORDER BY " +
            " t1.create_time DESC " +
            "</script>")
    List<SwErrorCorrectionVo> getErrorCorrections(Integer handleStatus);

    @Update("<script>" +
            " <foreach collection='arr' item='v' separator=';'> " +
            " UPDATE `tab_sw_error` SET `handle_status` = #{handleStatus} WHERE `error_id` = #{v} " +
            " </foreach> " +
            "</script>")
    void handleErrorCorrections(@Param("arr") String[] errorIdArr, @Param("handleStatus") Integer handleStatus);
}
